//
//  MissCell.m
//  Manage
//
//  Created by 杨康 on 2017/11/12.
//  Copyright © 2017年 杨康. All rights reserved.
//

#import "MissCell.h"

@implementation MissCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        
        self.imgView=[[UIImageView alloc]init];
        //可省略
        self.imgView.layer.masksToBounds=YES;
        self.imgView.layer.cornerRadius=4.0;
        //
        [self.contentView addSubview:self.imgView];
        self.imgView.backgroundColor=[UIColor colorE];
        
        
        
        
        
        
        self.nameLab=[[UILabel alloc]init];
        self.nameLab.textColor=[UIColor color3];
        self.nameLab.font=[UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.nameLab];
        
        
        
        self.colorLab=[[UILabel alloc]init];
        self.colorLab.textColor=[UIColor color9];
        self.colorLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.colorLab];
        
        
        
        self.storeNameLab=[[UILabel alloc]init];
        self.storeNameLab.textColor=[UIColor color9];
        self.storeNameLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.storeNameLab];
        
        
        
        self.timeLab=[[UILabel alloc]init];
        self.timeLab.textColor=[UIColor color9];
        self.timeLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.timeLab];
        
        
        
        self.addressLab=[[UILabel alloc]init];
        self.addressLab.textColor=[UIColor color6];
        self.addressLab.font=[UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.addressLab];
        
        
        
        self.moneyLab=[[UILabel alloc]init];
        self.moneyLab.text=@"悬赏金额：";
        self.moneyLab.textColor=[UIColor color3];
        self.moneyLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.moneyLab];
        
        
        
        
        self.coinLab=[[UILabel alloc]init];
        self.coinLab.textColor=[UIColor colorQ];
        self.coinLab.font=[UIFont systemFontOfSize:14];
        [self.contentView addSubview:self.coinLab];
        
        
        
        
        self.stateLab=[[UILabel alloc]init];
        self.stateLab.font=[UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.stateLab];
        self.stateLab.textAlignment=NSTextAlignmentCenter;
        self.stateLab.layer.masksToBounds=YES;
        self.stateLab.layer.cornerRadius=3;
        self.stateLab.layer.borderWidth=0.5;
        self.stateLab.layer.borderColor=[UIColor colorD].CGColor;
        
        
        
        self.lineLab=[[UILabel alloc]init];
        self.lineLab.backgroundColor=[UIColor colorF];
        [self.contentView addSubview:self.lineLab];
        
        
        
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    
    [self.imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.centerY.mas_equalTo(self.contentView);
        //可省略
        make.size.mas_equalTo(CGSizeMake(60, 60));
        
    }];
    
    
    
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(8);
        make.left.mas_equalTo(self.imgView.mas_right).mas_offset(10);
        
    }];
    
    
    
    [self.colorLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLab.mas_right).mas_offset(5);
        make.centerY.mas_equalTo(self.nameLab);
    }];
    
    
    
    
    [self.storeNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.colorLab.mas_right).mas_offset(5);
        make.centerY.mas_equalTo(self.nameLab);
        
    }];
    
    [self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(self.nameLab);
    }];
    
    
    
    [self.addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLab);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(self.nameLab.mas_bottom).mas_offset(5);
    }];
    
    
    
    
    [self.moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.addressLab);
        make.top.mas_equalTo(self.addressLab.mas_bottom).mas_offset(5);
    }];
    
    
    [self.coinLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.moneyLab.mas_right);
        make.centerY.mas_equalTo(self.moneyLab);
    }];
    
    
    
    
    
    
    
    
    
    [self.stateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(self.moneyLab);
        make.size.mas_equalTo(CGSizeMake(44, 20));
    }];
    
    
    
    [self.lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(-0.5);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 0.5));
    }];
    
    
}
-(void)setDataDic:(MissData *)dataDic
{
    if (![NSString isNULLString:dataDic.image]) {
        self.imgView.image =[UIImage imageNamed:dataDic.image];
    }
    self.nameLab.text=dataDic.name?dataDic.name:@"";
    self.colorLab.text=dataDic.color?dataDic.color:@"";
    self.storeNameLab.text=dataDic.storeName?dataDic.storeName:@"";
    self.timeLab.text=dataDic.time?dataDic.time:@"";
    self.addressLab.text=dataDic.address?dataDic.address:@"";
    self.coinLab.text=[NSString stringWithFormat:@"%@元",dataDic.coin?dataDic.coin:@""];
    
    NSString *state=dataDic.state?dataDic.state:@"";
    if ([state isEqualToString:@"1"]) {
        
        
        
        self.stateLab.text=@"待审核";
        self.stateLab.textColor=[UIColor colorQ];
        
    }
    else if ([state isEqualToString:@"2"])
    {
        
        
        self.stateLab.text=@"报失中";
        self.stateLab.textColor=[UIColor colorI];
    }
    else if ([state isEqualToString:@"3"])
    {
        
        
        self.stateLab.text=@"已找到";
        self.stateLab.textColor=[UIColor color9];
    }
    
    else if ([state isEqualToString:@"4"])
    {
        
        
        self.stateLab.text=@"已取消";
        self.stateLab.textColor=[UIColor color9];
    }else
    {
        
        
        self.stateLab.text=@" ";
        self.stateLab.textColor=[UIColor whiteColor];
    }
    
    _dataDic=dataDic;
}
@end
